//
//  UserManager.h
//  FinanceBBS
//
//  Created by mibo02 on 2017/12/15.
//  Copyright © 2017年 mibo02. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "UserInfo.h"

@class FoundRecommendModel;
typedef NS_ENUM(NSInteger, UserLoginType){
    kUserLoginTypeUnKnow = 0,//未知
    kUserLoginTypeWeChat,//微信登录
    kUserLoginTypeQQ,///QQ登录
    kUserLoginTypePwd,///账号登录
};

typedef void (^loginBlock)(BOOL success,NSInteger code, NSString * des);

#define kIsLogin [UserManager sharedUserManager].isLogined
#define kCurUser [UserManager sharedUserManager].curUserInfo
#define kUserManager [UserManager sharedUserManager]

@interface UserManager : NSObject
//单例
SINGLETON_FOR_HEADER(UserManager)
//当前用户
@property (nonatomic, strong) UserInfo *curUserInfo;
@property (nonatomic, assign) UserLoginType loginType;
@property (nonatomic, assign) BOOL isLogined;
@property (nonatomic, copy) loginBlock loginBlock;
@property (nonatomic, copy) NSString* lastAccount;

#pragma mark - ——————— 登录相关 ————————

/**
 自动登录
 
 @param completion 回调
 */
-(void)autoLoginToServer:(loginBlock)completion;

/**
    获取个人信息
 */
- (void)autoGetUserInformation:(loginBlock)completion;
/**
 退出登录
 
 @param completion 回调
 */
- (void)logout:(void (^)(BOOL success, NSString *des))completion;

/**
 加载缓存用户数据
 
 @return 是否成功
 */
-(BOOL)loadUserInfo;
-(void)saveUserInfo;
///登录成功
-(void)LoginSuccess:(id )responseObject completion:(loginBlock)completion;

///保存搜索的词
- (void)saveSeachWord:(NSString *)word;
- (NSArray *)haveSearchWords;
- (void)clearSearchWords;
///群组搜索
- (void)saveGroupSeachWord:(NSString *)word;
- (NSArray *)haveGroupSearchWords;
- (void)clearGroupSearchWords;

///保存最近使用的Dapp
- (void)saveRecentlyUsed:(FoundRecommendModel*)dapp;
- (NSArray <FoundRecommendModel*>*)getRecentlyUsed;

///进Dapp提示
- (void)saveDappAggreeId:(NSString *)dappId;
- (NSArray *)haveDappAggreeId;
@end
